package controller;

import pojo.Book;
import dao.impl.BookDaoImpl;
import service.BookService;
import view.AddBook;
import view.QueryView;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

public class QueryViewListener implements ActionListener {
    private QueryView queryView;
    private AddBook addBook;
    private BookService bookService = new BookService();
    private Book book;
    public QueryViewListener(QueryView queryView){
        this.queryView=queryView;

    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if(e.getActionCommand().equals("查询")){
            bookService=new BookService();
            List<Book> bookList = bookService.searchFuzzy(queryView.getTextField1().getText());
            queryView.refresh(bookList);
        }
        if(e.getActionCommand().equals("新增图书")) {
            new AddBook(queryView);
        }
    }
}